
from fastapi.responses import Response, JSONResponse

from common.enum.error import ErrorEnum

class Result:
    def __init__(self, code: int = 200, msg: str = None, data: object = None):
        self.code = code
        self.msg = msg
        self.data = data

    @staticmethod
    def success(data = None):
        return Result(
            data=data
        )

    @staticmethod
    def error(errorEnum: ErrorEnum):
        return Result(
            code=errorEnum.code,
            msg=errorEnum.msg
        )
    
    @staticmethod
    def errorCode(statusCode: int = 400):
        return Response(
            status_code=statusCode
        )
